<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_address.*" %>
<%@page import="java.util.*" %>
<%@ page import="com.lmpop.trade.ts_area.Ts_areaInfo" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
	String cust_id="";
	if(session.getAttribute("session_cust_id")!=null){
		cust_id  = session.getAttribute("session_cust_id").toString();
	}
	Hashtable ti_address = new Hashtable();

	
	String req_addr_id="";
	
	String req_consignee="";
	
	String req_level_no="";
	
	String req_area_attr="";
	
	String req_cust_name="";
	
	String req_cellphone="";
	
   
   if(request.getParameter("req_cust_name")!=null && !request.getParameter("req_cust_name").equals("")){
		req_cust_name = request.getParameter("req_cust_name");
		ti_address.put("cust_name",req_cust_name);
	}
   
   if(request.getParameter("req_addr_id")!=null && !request.getParameter("req_addr_id").equals("")){
		req_addr_id = request.getParameter("req_addr_id");
		ti_address.put("addr_id",req_addr_id);
	}
	
	if(request.getParameter("req_consignee")!=null && !request.getParameter("req_consignee").equals("")){
		req_consignee = request.getParameter("req_consignee");
		ti_address.put("consignee",req_consignee);
	}
	
	if(request.getParameter("req_level_no")!=null && !request.getParameter("req_level_no").equals("")){
		req_level_no = request.getParameter("req_level_no");
		ti_address.put("level_no",req_level_no);
	}
	
	if(request.getParameter("req_area_attr")!=null && !request.getParameter("req_area_attr").equals("")){
		req_area_attr = request.getParameter("req_area_attr");
		ti_address.put("area_attr",req_area_attr);
	}
	
	if(request.getParameter("req_cellphone")!=null && !request.getParameter("req_cellphone").equals("")){
		req_cellphone = request.getParameter("req_cellphone");
		ti_address.put("cellphone",req_cellphone);
	}
	

	Ti_addressInfo ti_addressInfo = new Ti_addressInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_addressInfo.getListByPage(ti_address,Integer.parseInt(iStart),limit);
	int counter = ti_addressInfo.getCountByObj(ti_address);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?iStart=",Integer.parseInt(iStart),limit);
	
	
	Ts_areaInfo ts_areaInfo = new Ts_areaInfo();
	
	Map areaMap = ts_areaInfo.getAreaClass();
%>
<html>
  <head>
    
    <title>会员收货地址管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js'></script>
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="index.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>会员收货地址管理</h1>
			</td>
			
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<!--
	<table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>-----------------</h4>
		  <span>1----------------。</span><br/>
		  <span>2----------------。</span>
		  </td>
        </tr>
      </table>
      <br/>
	  -->
	  
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
			
			       会员:<input name="req_cust_name" type="text" />&nbsp;
				
				   收货人姓名:<input name="req_consignee" type="text" />&nbsp;
		  		
					地区:
					<select name="province" id="province" onclick="setCitys(this.value)">
					<option value="">省份</option> 
					</select>

					<select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)">
						<option value="">地级市</option> 
					 </select>
					<select name="city_code" id="city_code" >
						<option value="">市、县级市、县</option> 
					</select>				
					<input name="req_area_attr" id="req_area_attr" type="hidden" />
			<input name="searchInfo" type="button" value="搜索" onclick="searcherForm();"/>	
			</td>
		</tr>
	</table>
    
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center">
			<input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
			<th>会员</th>
				
		  	<th>收货人姓名</th>
		  	
		  	<th>优先级</th>		  	
		  	
		  	<th>地区</th>
		  	
			<th width="10%">修改</th>
	  		<th width="10%">删除</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String addr_id="",consignee="",cust_name="",level_no="",email="",area_attr="",address="",post_code="",tel="",cellphone="",best_time="",in_date="",user_id="",remark="";
		  			  	if(map.get("addr_id")!=null) addr_id = map.get("addr_id").toString();
						if(map.get("cust_name")!=null) cust_name = map.get("cust_name").toString();
						if(map.get("consignee")!=null) consignee = map.get("consignee").toString();
						if(map.get("level_no")!=null) level_no = map.get("level_no").toString();
						if(map.get("email")!=null) email = map.get("email").toString();
						if(map.get("area_attr")!=null) area_attr = map.get("area_attr").toString();
						if(map.get("best_time")!=null) best_time = map.get("best_time").toString();
						if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
						if(in_date.length()>19)in_date=in_date.substring(0,19);
						StringBuffer areaAttr = new StringBuffer();
						if(!area_attr.equals("")){
						  String areaIds[] = area_attr.split("\\|");	
						  for(String areaId:areaIds){
							 if(areaMap!=null){
								if(areaMap.get(areaId)!=null){
									areaAttr.append("<a href='index.jsp?req_area_attr="+areaId+"'>"+areaMap.get(areaId).toString() + "</a> ");
								}                  
							  }                 
						   }		    
						}
  	
		  %>
		
		<tr>
			<td width="5%" align="center">
			<input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=addr_id %>" /></td>
			
			<td><%=cust_name%></td>
			
		  	<td><%=consignee%></td>
		  	
		  	<td><%=level_no%></td>
		  	
		  	
		  	<td><%=areaAttr%></td>
		  	
		  	<td width="10%"><a href="updateInfo.jsp?addr_id=<%=addr_id %>"><img src="/program/admin/images/edit.gif" title="修改" /></a></td>
	  		<td width="10%"><a href="javascript:deleteOneInfo('<%=addr_id%>','7212');"><img src="/program/admin/images/delete.gif" title="删除" /></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="7212" />
	  </form>
</body>

</html>
